package com.atguigu.composite;

import java.util.ArrayList;
import java.util.List;

//可以不写这个类，将University 和 College都看做是有叶子节点的类，创建类的时候，取名不一样就行了
//College 就用University那个类
public class College extends OrganizationComponent {

	//List 中存放的是Department
	List<OrganizationComponent> organizationComponents = new ArrayList<OrganizationComponent>();

	//构造器
	public College(String name, String des) {
		super(name, des);
	}
	
	//重写add
	@Override
	protected void add(OrganizationComponent organizationComponent) {
		//将来实际业务中，College 的 add 和 University add 不一定完全一样
		organizationComponents.add(organizationComponent);
	}
	
	//重写remove
	@Override
	protected void remove(OrganizationComponent organizationComponent) {
		organizationComponents.remove(organizationComponent);
	}

	//print方法，就是输出University 包含的学院
	@Override
	protected void print() {
		System.out.println("--------"+getName()+"-----------------");
		//遍历organizationComponents
		for (OrganizationComponent organizationComponent : organizationComponents) {
			organizationComponent.print();
		}
	}


}
